<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>生产派工单审核（点击审核）</title>
    <link rel="shortcut icon" href="favicon.ico">
    <link href="/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="/css/font-awesome.min.css?v=4.4.0" rel="stylesheet">
    <link href="/css/animate.css" rel="stylesheet">
    <link href="/css/style.css?v=4.1.0" rel="stylesheet">
    <link href="/bootstraptable/bootstrap-table.css" rel="stylesheet">
</head>
<body>
<div style="color: #0e9aef">您正在做的业务是：生产管理--生产调度管理--制定生产派工单</div>

<div class="container">
    <form class="form-horizontal" id="query_send_work_order_form">
        <div style="text-align: right">
            <label class="radio-inline">
                <input type="radio" name="checkTag" value="S001-2">未通过
            </label>
            <label class="radio-inline">
                <input type="radio" name="checkTag" value="S001-1">通过
            </label>
            <button type="button" id="sure_btn" class="btn btn-default">确认</button>
            <button type="button" class="btn btn-default" onclick="history.back(-1);">返回</button>
        </div>
        <div class="panel panel-default" style="margin-top: 10px;">

            <div class="panel-heading">
                <div class="panel-title">
                    <h3 style="margin-top: 30px;text-align: center;">生产派工单</h3>
                </div>
            </div>
            <div class="panel-body">
                <div class="form-group">
                    <div class="col-md-6">
                        <label class="col-md-4 control-label">派工单编号</label>
                        <div class="col-md-8">
                            <input type="text" class="form-control" name="manufactureId" id="manufactureId" readonly
                                   style="border: none;background-color: white">
                        </div>
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-md-6">
                        <label class="col-md-4 control-label">产品编号：</label>
                        <div class="col-md-8">
                            <input type="text" class="form-control" name="productId" id="productId"
                                   style="border: none;background-color: white"/>
                        </div>
                    </div>
                    <div class="col-md-6">
                        <label class="col-md-4 control-label">产品名称：</label>
                        <div class="col-md-8">
                            <input type="text" class="form-control" name="productName" id="productName"
                                   style="border: none;background-color: white"/>
                        </div>
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-md-6">
                        <label class="col-md-4 control-label">数量：</label>
                        <div class="col-md-8">
                            <input type="text" class="form-control" name="amount" id="amount"
                                   style="border: none; background-color: white" readonly/>
                        </div>
                    </div>
                    <div class="col-md-6">
                        <label class="col-md-4 control-label">工单制定人：</label>
                        <div class="col-md-8">
                            <input type="text" class="form-control" name="designer" id="designer"
                                   style="border: none; background-color: white" readonly/>
                        </div>
                    </div>
                </div>

                <table id="send_work_order_table"></table>

                <div class="form-group" style="margin-top: 10px;">
                    <div class="col-md-6">
                        <label class="col-md-4 control-label">工时总成本：</label>
                        <div class="col-md-8">
                            <input type="text" class="form-control" name="labourCostPriceSum" id="labourCostPriceSum"
                                   style="border: none;background-color: white" readonly/>
                        </div>
                    </div>
                    <div class="col-md-6">
                        <label class="col-md-4 control-label">物料总成本：</label>
                        <div class="col-md-8">
                            <input type="text" class="form-control" name="moduleCostPriceSum" id="moduleCostPriceSum"
                                   style="border: none;background-color: white" readonly/>
                        </div>
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-md-6">
                        <label class="col-md-4 control-label">登记人：</label>
                        <div class="col-md-8">
                            <input type="text" class="form-control" name="register" id="register"
                                   style="border: none;border-bottom: 1px solid black"/>
                        </div>
                    </div>
                    <div class="col-md-6">
                        <label class="col-md-4 control-label">登记时间：</label>
                        <div class="col-md-8">
                            <input type="text" class="form-control" name="registerTime" id="registerTime"
                                   style="border: none;background-color: white" readonly/>
                        </div>
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-md-6">
                        <label class="col-md-4 control-label">审核人：</label>
                        <div class="col-md-8">
                            <input type="text" class="form-control" name="checker" id="checker"
                                   style="border: none;border-bottom: 1px solid black"/>
                        </div>
                    </div>
                    <div class="col-md-6">
                        <label class="col-md-4 control-label">审核时间：</label>
                        <div class="col-md-8">
                            <input type="text" class="form-control" name="checkTime" id="checkTime"
                                   style="border: none;background-color: white" readonly/>
                        </div>
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-md-12">
                        <label class="col-md-2 control-label">备注：</label>
                        <div class="col-md-8">
                            <textarea cols="50" rows="3" class="form-control" style="resize: none;" id="remark"
                                      name="remark"></textarea>
                        </div>
                    </div>
                </div>
                <input type="hidden" name="id" id="id">
                <input type="hidden" name="applyIdGroup" id="applyIdGroup">
            </div>
        </div>
    </form>
</div>

<div class="modal fade" id="send_work_modal">
    <div class="modal-dialog modal-lg">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal">
                    <span onclick="clearInfo()">&times;</span>
                </button>
            </div>
            <div class="modal-body">
                <div class="panel panel-default">
                    <div class="panel-heading" style="background-color: white">
                        <div class="panel-title">
                            <h3 style="margin-top: 30px;text-align: center;">工序物料单</h3>
                        </div>
                    </div>
                    <div class="panel-body">
                        <form class="form-horizontal">
                            <div class="form-group">
                                <div class="col-md-6">
                                    <label class="control-label col-md-4">派工单编号：</label>
                                    <div class="col-md-8">
                                        <input type="text" class="form-control" readonly name="manufactureId"
                                               id="manufId" style="border: none;background-color: white;">
                                    </div>
                                </div>
                                <div class="col-md-6">
                                    <label class="control-label col-md-4">工序名称：</label>
                                    <div class="col-md-8">
                                        <input type="text" class="form-control" readonly name="procedureName"
                                               id="procedureName" style="border: none;background-color: white;">
                                    </div>
                                </div>
                            </div>
                            <table id="send_work_modal_table"></table>
                        </form>
                    </div>
                </div>

            </div>
            <div class="modal-footer">
                <button type="button" id="back_btn" class="btn btn-default col-md-2 col-md-offset-10">返回
                </button>
            </div>
        </div>
    </div>
</div>


<!-- 全局js -->
<script src="/js/jquery.min.js?v=2.1.4"></script>
<script src="/js/bootstrap.min.js?v=3.3.6"></script>
<script src="/js/plugins/metisMenu/jquery.metisMenu.js"></script>
<script src="/js/plugins/slimscroll/jquery.slimscroll.min.js"></script>
<script src="/js/plugins/layer/layer.min.js"></script>

<!-- 自定义js -->
<script src="/js/hAdmin.js?v=4.1.0"></script>
<script src="/js/currentTime.js"></script>

<!-- 第三方插件 -->
<script src="/js/plugins/pace/pace.min.js"></script>

<!--BootstrapTable-->
<script src="/bootstraptable/bootstrap-table.min.js"></script>
<script src="/bootstraptable/locale/bootstrap-table-zh-CN.min.js"></script>

<script>
    $(function () {
        let rid = localStorage.getItem("rid")
        $("#query_send_work_order_form #checkTime").val(add(fortime()))

        $.post("/manufacture/detail/getIdQuery", {"rid": rid}, function (res) {
            $("#query_send_work_order_form #manufactureId").val(res.manufactureId)
            $("#query_send_work_order_form #id").val(res.id)
            $("#query_send_work_order_form #productId").val(res.productId)
            $("#query_send_work_order_form #productName").val(res.productName)
            $("#query_send_work_order_form #amount").val(res.amount)
            $("#query_send_work_order_form #designer").val(res.designer)
            $("#query_send_work_order_form #labourCostPriceSum").val(res.labourCostPriceSum)
            $("#query_send_work_order_form #moduleCostPriceSum").val(res.moduleCostPriceSum)
            $("#query_send_work_order_form #register").val(res.register)
            $("#query_send_work_order_form #registerTime").val(formater(res.registerTime))
            $("#query_send_work_order_form #remark").val(res.remark)
            $("#query_send_work_order_form #applyIdGroup").val(res.applyIdGroup)
        })

        $("#send_work_modal #back_btn").click(function () {
            $("#send_work_modal_table").bootstrapTable("destroy")
            $("#send_work_modal").modal("hide")
        })

        $("#query_send_work_order_form #send_work_order_table").bootstrapTable({
            method: "post",
            contentType: "application/x-www-form-urlencoded",
            url: "/manufacture/detail/getIdQueryDesign",
            // 数据行交替样式
            striped: true,
            // 是否是服务器端分页：server表示服务器端，client表示前端分页
            sidePagination: 'server',
            queryParams: function (params) {
                let obj = {
                    pid: rid
                }
                return obj;
            },
            // 表格列标题
            columns: [{
                title: "序号",
                field: "detailsNumber"
            }, {
                title: "工序名称",
                field: "procedureName"
            }, {
                title: "工序编号",
                field: "procedureId",
            }, {
                title: "描述",
                field: "procedureDescribe"
            }, {
                title: "工时数（小时）",
                field: "labourHourAmount"
            }, {
                title: "工时成本小计（元）",
                field: "subtotal",
            }, {
                title: "物料成本小计",
                field: "moduleSubtotal"
            }, {
                title: "查看物料",
                formatter: function (value, row, index) {
                    return `<a href="javascript:showProduct(${row.id})">查看物料</a>`
                }
            }]
        })

        $("#query_send_work_order_form #sure_btn").click(function () {
            let rad = $("#query_send_work_order_form :radio[name='checkTag']:checked")
            if (rad.length == 0) {
                alert("请选择审核状态")
                return
            }
            let parms = $("#query_send_work_order_form").serialize()
            $.post("/manufacture/detail/manufactureReview", parms, function (res) {
                if(res){
                    window.location = "query_production_dispatch_work_orderUI"
                }

            })
        })
    })

    function showProduct(id) {

        $("#send_work_modal").modal("show")

        $.post("/manufacture/detail/getIdQueryNumber", {"id": id}, function (res) {
            console.log(res)
            $("#send_work_modal #procedureName").val(res[0])
            $("#send_work_modal #manufId").val(res[1])
        })

        $("#send_work_modal_table").bootstrapTable({
            method: "post",
            contentType: "application/x-www-form-urlencoded",
            url: "/manufacture/detail/getIdQueryDetails",
            // 数据行交替样式
            striped: true,
            // 是否是服务器端分页：server表示服务器端，client表示前端分页
            sidePagination: 'server',
            queryParams: function (params) {
                let obj = {
                    pid: id
                }
                return obj;
            },
            // 表格列标题
            columns: [{
                title: "序号",
                field: "detailsNumber"
            }, {
                title: "物料名称",
                field: "productName"
            }, {
                title: "物料编号",
                field: "productId",
            }, {
                title: "描述",
                field: "procedureDescribe"
            }, {
                title: "本工序数量",
                field: "amount"
            }, {
                title: "单位",
                field: "amountUnit",
            }, {
                title: "单价（元）",
                field: "costPrice",

            }, {
                title: "小计（元）",
                field: "subtotal",
            }]
        })
    }

    function clearInfo() {
        $("#send_work_modal_table").bootstrapTable("destroy")
    }
</script>
</body>
</html>